# -*- coding: utf-8 -*-
#
class User < ActiveRecord::Base
	def getPots()
		ret = { 
			1 => {'item_num' => self.p1_item_num,
				'special_num' => self.p1_special_num,
				'complete_pattern' => self.p1_complete_pattern
			},
			2 => {'item_num' => self.p2_item_num,
				'special_num' => self.p2_special_num,
				'complete_pattern' => self.p2_complete_pattern
			},
			3 => {'item_num' => self.p3_item_num,
				'special_num' => self.p3_special_num,
				'complete_pattern' => self.p3_complete_pattern
			},
			4 => {'item_num' => self.p4_item_num,
				'special_num' => self.p4_special_num,
				'complete_pattern' => self.p4_complete_pattern
			},
			5 => {'item_num' => self.p5_item_num,
				'special_num' => self.p5_special_num,
				'complete_pattern' => self.p5_complete_pattern
			}
		}
		return ret
	end
   
   
	##--------------------
	def setPots(pots)
		self.p1_item_num = pots[1]['item']
		self.p1_special_num = pots[1]['special']
		self.p2_item_num = pots[2]['item']
		self.p2_special_num = pots[2]['special']
		self.p3_item_num = pots[3]['item']
		self.p3_special_num = pots[3]['special']
		self.p4_item_num = pots[4]['item']
		self.p4_special_num = pots[4]['special']
		self.p5_item_num = pots[5]['item']
		self.p5_special_num = pots[5]['special']
	end

	##--------------------
	def setConplete(potid)
		rnd = (rand(BKH_SPECIAL_LIMIT) +1) 
		if potid == 1 then
			self.p1_complete_pattern = rnd
		elsif  potid == 2 then
			self.p2_complete_pattern = rnd
		elsif  potid == 3 then
			self.p3_complete_pattern = rnd
		elsif  potid == 4 then
			self.p4_complete_pattern = rnd
		elsif  potid == 5 then
			self.p5_complete_pattern = rnd
		end
	end

	##--------------------
	def checkComplete(potid)
		ret = false
		if potid == 1 and self.p1_complete_pattern == BKH_IS_NOT_COMPLETED and self.p1_item_num == BKH_ITEM_LIMIT then
			ret = true
		elsif potid == 2 and self.p2_complete_pattern == BKH_IS_NOT_COMPLETED and self.p2_item_num == BKH_ITEM_LIMIT then
			ret = true
		elsif potid == 3 and self.p3_complete_pattern == BKH_IS_NOT_COMPLETED and self.p3_item_num == BKH_ITEM_LIMIT then
			ret = true
		elsif potid == 4 and self.p4_complete_pattern == BKH_IS_NOT_COMPLETED and self.p4_item_num == BKH_ITEM_LIMIT then
			ret = true
		elsif potid == 5 and self.p5_complete_pattern == BKH_IS_NOT_COMPLETED and self.p5_item_num == BKH_ITEM_LIMIT then
			ret = true
		end
		return ret
	end

end
